﻿namespace Nomo.PathFindingModule
{
    /// <summary>
    /// 曼哈顿网格距离计算器。
    /// </summary>
    public sealed class ManhattanGridDistanceCalculator : IGridDistanceCalculator
    {
        double IGridDistanceCalculator.CalculatorDistance(Grid a, Grid b)
        {
            if (a == null)
            {
                throw new System.ArgumentNullException(nameof(a));
            }

            if (b == null)
            {
                throw new System.ArgumentNullException(nameof(b));
            }

            return System.Math.Abs(a.RowIndex - b.RowIndex) + System.Math.Abs(a.ColumnIndex - b.ColumnIndex);
        }
    }
}
